package com.atguigu.lease.web.admin.custom.config.converter;

import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class StringToStatusTypeConverter implements Converter<String,ItemType> {
    @Override
    public ItemType convert(String code) {
        ItemType[] values = ItemType.values();
        for (ItemType i:values
             ) {
            if (code.equals(i.getCode().toString())){
                return i;
            }
        }
        throw new IllegalArgumentException();
    }
}
